import com.beust.jcommander.JCommander;
import com.gq.utils.Crypto;


public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		ArgumentsEnv env = new ArgumentsEnv();
		JCommander cmd = new JCommander(env);
		try {
			cmd.parse(args);
			Crypto c = new Crypto(env.getPwd());
			if (env.isEncrypt()) {
				System.out.print(c.encryptToBase64(env.getClearText()));
			} else if(env.isDecrypt()) {
				System.out.print(c.decryptFromBase64(env.getEncryptedCipherText()));
			}
			if (args.length == 0) throw new Exception("show argument usage");
		} catch(Exception e) {
			cmd.usage();
		}
	}

}
